/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.java.editor;

import com.java.mapbean.Loaisach;
import com.java.service.LoaiSachService;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author quannq
 */
public class LoaiSachEditor extends PropertyEditorSupport {

    public LoaiSachService loaiSachService;

    public LoaiSachEditor(LoaiSachService loaiSachService) {
        super();
        this.loaiSachService = loaiSachService;
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (!text.equals("")) {
            Loaisach emp = loaiSachService.findId(Integer.parseInt(text));
            setValue(emp);
        } else {
            setValue(null);
        }
    }
}
